/*
* ============================================================================
*  Name        : example_002.cpp
*  Part of     : Finite state machine examples
*  Description : Hello World! 
*  Version     : %version: %
*  
*
* ============================================================================
*/
#include "example_002.h"
#include "example_002.hxx" // State machine source code is here

/**
 * @file example_002.cpp
 *
 * @details
 * Time limited states
 *
 * @ingroup StateMachineExamples
 */
using namespace sea_examples;

// ----------------------------------------------------------------------------
// 
// ----------------------------------------------------------------------------
void sea_examples::launch_example_002( )
{
    SEA_TRACE_ENTRY( );

    // 1. Instantiate state machine
    // 2. Compile the source code or reuse compiled one
    // 3. Execute state machine. The function will not leave until state machine is finished in 'sync' and 'parser' modes
    // 4. Release local state machine reference
    // 5. Terminate state machine engine at the application exit. It also terminates all state machines.

    {
        sea::ref< HelloTheWorld_002 > sm;
        sm << NEW HelloTheWorld_002;
        if ( sm->create( 0, HelloTheWorld_002_src ) != eOk ){ /* See Error codes */ }
        if ( sm->start( ) != eOk ){ /* See Error codes */ }
    }
    Engine::terminate( );
}

// ----------------------------------------------------------------------------
// Ctor. Base StateMachine class requires user class name to register in the 
// framework meta system
// ----------------------------------------------------------------------------
HelloTheWorld_002::HelloTheWorld_002( ) : 
    StateMachine( STATEMACHINE_NAME )
{
}

// ----------------------------------------------------------------------------
// Action function. Print 'Hello'
// ----------------------------------------------------------------------------
ACT_IMPL( HelloTheWorld_002, say_hello )
{
    SEA_UNUSED_PARAM( );
    SEA_TRACE( "\n<<<< Hello >>>>\n" ); 
}

// ----------------------------------------------------------------------------
// Action function. Print 'sea'
// ----------------------------------------------------------------------------
ACT_IMPL( HelloTheWorld_002, say_sea )
{
    SEA_UNUSED_PARAM( );
    SEA_TRACE( "\n<<<< SEA >>>>\n" ); 
}

// ----------------------------------------------------------------------------
// Action function. Print 'world'
// ----------------------------------------------------------------------------
ACT_IMPL( HelloTheWorld_002, say_world )
{
    SEA_UNUSED_PARAM( );
    SEA_TRACE( "\n<<<< World! >>>>\n" ); 
}

